#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef unsigned long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}


const int mod = 998244353;
const int N = 1e5 + 10;

string s;

LL quick_power(LL a, LL k, LL p)  // 求a^k mod p
{
    LL res = 1 % p;
    while (k)
    {
        if (k & 1) res = (LL)res * a % p;
        a = (LL)(a % p) * (a % p) % p;
        k >>= 1;
    }
    return res;
}

inline void solution() {
    cin >> s;
    unordered_map<string, LL> mp;
    int cnt[N];
    int a[N];
    for (int i = 0; i < s.size(); i ++ ) {
        char c = s[i];
        if (c == 'n') {
            mp["n"] ++ ;
            mp["nun"] += mp["nu"];
        } else if (c == 'u') {
            mp["nu"] += mp["n"];
        } else if (c == 'h') {
            mp["nunhehheh"] += mp["nunhehhe"];
            mp["nunhehh"] += mp["nunheh"];
            mp["nunheh"] += mp["nunhe"];
            mp["nunh"] += mp["nun"];
        } else if (c == 'e') {
            mp["nunhe"] += mp["nunh"];
            mp["nunhehhe"] += mp["nunhehh"];
        }
        cnt[i] = mp["nunhehheh"];
    }
    int t = 0;
    for (int i = s.size() - 1; i >= 0; i -- ) 
        if (s[i] == 'a') a[i] = ++ t ;
    LL res = 0;
    for (int i = 0; i < s.size(); i ++ ) {
        if (s[i] == 'a') {
            res = (res % mod + ((cnt[i] % mod )* quick_power(2, a[i] - 1, mod)) % mod) % mod;
        }
    }
    cout << res << endl;
}


int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    int T;
    cin >> T;
    while (T -- ) {
       solution();
    }
    return 0;
}